<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>HomeWork_Day1</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        body {
            margin: 0;
            padding: 0;
            height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
        }


        #context {
            margin-bottom: 10px;
        }

        #container button {
            width: 100px;
            height: 50px;
            position: relative;
            border-radius: 4px;
            cursor: pointer;
            border: 0;
            margin-left: 5px;
        }

        #container button::before {
            content: "";
            position: absolute;
            top: 0;
            left: 0;
            bottom: 0;
            right: 0;
            margin: -4px;
            z-index: -1;
            background: linear-gradient(115deg, #4fcf70, #fad648, #a767e5, #12bcfe, #44ce7b);
        }


        /* #container button {
            width: 100px;
            height: 50px;
            position: relative;
            z-index: 2;

            border-radius: 4px;
            box-sizing: border-box;
            overflow: hidden;
            padding: 3px;
            cursor: pointer;
        }

        #container button::before {
            content: "";
            position: absolute;
            top: 0;
            left: 0;
            width: 200%;
            height: 100%;
            margin: -4px;
            background: linear-gradient(115deg, #4fcf70, #fad648, #a767e5, #12bcfe, #44ce7b);
            background-size: 50% 100%;
        } */





        /* button:hover::before {
            animation: gradient 1s linear infinite;
        }

        @keyframes gradient {
            to {
                transform: translateX(-50%);
            }
        } */
    </style>
</head>

<body>
    <div id="container">
        <p id="context">Hello Word!</p>
        <button id="toRed">变为红色</button>
        <button id="reset">复原</button>
    </div>
    <script>
        window.onload = function () {
            function handleToRed() {
                context.style.color = "red";
            }
            function handleReset() {
                context.style.color = "";
            }
            let context = document.querySelector("#context");
            let toRed = document.querySelector("#toRed");
            let reset = document.querySelector("#reset");

            toRed.addEventListener("click", handleToRed);
            reset.addEventListener("click", handleReset);
        }
    </script>
</body>

</html>